<%@ page contentType="text/html;charset=UTF-8" %>
<%--<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>--%>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录界面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-4"></div>
        <%--<form action="/demo/score/updateScore" method="post">--%>
            <div class="col-md-4">
                <p class="h1 text-center">学生成绩修改</p>
                <div>
                    <input type="text" v-model="stuScoreMs.examType" class="form-control" >
                </div>
                <br>
                <div>
                    <input type="text" v-model="stuScoreMs.stuId" class="form-control" >
                </div>
                <br>
                <div>
                    <input type="text" v-model="stuScoreMs.term" class="form-control" >
                </div>
                <br>
                <div>
                    <input type="text" v-model="stuScoreMs.major" class="form-control" >
                </div>
                <br>
                <div>
                    <input type="text" v-model="stuScoreMs.name" class="form-control">
                </div>
                <br>
                <div>
                    <input type="text" v-model="stuScoreMs.courseGrade" class="form-control" >
                </div>
                <br>
                <button type="button" @click="edit()" class="btn btn-info btn-block" >提交</button>
            </div>
        <%--</form>--%>
        <div class="col-md-4">
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        id:'',
        data: {
            stuScoreMs:{},

        },
        methods:
            {
                getOne:function () {
                    $.ajax({
                        url: '/demo/score/getOne',
                        type: 'post',
                        data:{id: this.id},
                        dataType:'json',
                        success:function(result){
                            console.log(result);
                            app.stuScoreMs = result;
                            console.log("-----" + app.stuScoreMs)
                        }
                    });
                }
                ,
                edit: function () {
                    $.ajax({
                        url: "/demo/score/updateScore",
                        type: 'post',
                        data: JSON.stringify(this.stuScoreMs),
                        contentType:'application/json',
                        dataType:'json',
                        success: function (result) {
                            if (result.indexOf("成功")>=0) {
                                window.location.href = "/demo/score/index4";
                            }
                        },
                        error: function (result) {
                            alert("失败");
                            window.location.href = "/demo/score/updateScore";
                        }
                    })
                }
            }
    });
    $(function () {
        app.id = '${id}';
        app.getOne();
    })

</script>

</body>
</html>

